import { exec } from 'shelljs'
import chalk from 'chalk'
import json from './json/domain_model.json'
import rimraf from 'rimraf'

rimraf.sync('demo/java-demo')

const command = `npx yo tianzhi-java demo/java-demo --domainJSON ${JSON.stringify(JSON.stringify(json))}`

console.log(chalk.cyan(command))

const child = exec(command, { async: true, silent: true })

child.stderr.on('end', function (error) {
    console.error(error)
})

child.stdout.on('end', function (data) {
  console.log(`${chalk.green('运行完成')}，请查看 ${chalk.bgCyan('demo/java-demo')}`)
  console.log(data, 'data')
})
